/*************************************************
Author: will
Date: 11/15/2012
Description:
Notes: 
*************************************************/

#ifndef __CGardenMgr_h__
#define __CGardenMgr_h__

#include "CUserGarden.h"
#include "CGardenConfig.h"

class MsgGardenInfo;
class CGardenMgr
{
public:
    CGardenMgr()
    {

    }

    int LoadConfig(const char* szCfgPath);

    //花园所有者获取藏宝锄数量
    int OwnerGetHoeCount(CUesrGardenData& stUserGarden);

    //获取地精数量
    int GetGoblinCount(const CUesrGardenData& stUserGarden, int iNowtime);

    //获取挖宝锄数量
    int GetHoeCount(CUesrGardenData& stUserGarden);

    //获取花园信息
    int GetGardenInfo(CUesrGardenData& stUserGarden, int iNowTime, bool bIsGetOwn, MsgGardenInfo& stGardenInfo);

    //检查睡眠时间
    int CheckSleepTime(CUesrGardenData& stUserGarden, int iNow);

    //检查是否可以种花
    int CheckPlantFlower(CUesrGardenData& stUserGarden, unsigned char ucLandPos, unsigned char ucFlowerID, int iNow);

    //种花
    int PlantFlower(CUesrGardenData& stUserGarden, unsigned char ucLandPos, 
                    unsigned short usPartnerID, unsigned char ucFlowerID, int iNow, bool bFlushGoblin);

    //检查是否可以摘花
    int CheckPickFlower(CUesrGardenData& stUserGarden, unsigned char ucLandPos, int iNow);

    //摘花
    int PickFlower(CUesrGardenData& stUserGarden, unsigned char ucLandPos, unsigned short usNowLevel, 
                            int iNow, unsigned int& uiExp);

    //种花时检查经验是否会超过主角
    bool CheckExpExceed(CUesrGardenData& stUserGarden, unsigned char ucLandPos, uint64 u64Exp, uint64 u64MaxExp, unsigned short usNowLevel, unsigned char ucFlowerID);

    //获取花卉经验
    int GetFlowerExp(unsigned short usNowLevel, unsigned char ucFlowerID, unsigned int& uiExp);

    //购买和升级土地
    int BuyLand(CUesrGardenData& stUserGarden);

    //获取当前土地最大等级与位置
    int GetLandLevelAndPos(CUesrGardenData& stUserGarden, unsigned char& ucNowLandLevel, unsigned char& ucNowPos);

    //挖宝
    int DigBox(CUesrGardenData& stUserGarden, unsigned char ucLandPos);

    //拾取宝箱
    int PickBox(CUesrGardenData& stUserGarden, unsigned char ucLandPos, unsigned short usRoleLevel, unsigned int& uiSilver);

    //捡挖宝锄
    int PickHoe(CUesrGardenData& stUserGarden);

    //获取剩余成熟时间
    int GetLeftGrownSec(CUesrGardenData& stUserGarden, unsigned char ucLandPos, int& iLeftSec, int iNow);

    //加速成长
    int SpeedUpGrown(CUesrGardenData& stUserGarden, unsigned char ucLandPos, int iNow, CPlayerBaseInfo& stPlayerBaseInfo);

    //设置休眠时间
    int SetSleepTime(CUesrGardenData& stUserGarden, unsigned int uiSleepTime, int iNow);

    //驱赶地精
    int CatchGoblin(CUesrGardenData& stUserGarden, CUesrGardenData& stFriendUserGarden, unsigned int uiGID, 
                unsigned int uiFriendGID, unsigned short usFriendLevel, unsigned int& uiBonusExp, int iNow, unsigned short& usGetSeedCount);

    //购买挖宝锄
    int BuyHoe(CUesrGardenData& stUserGarden, int& iGold, int iNow, int iMaxCanBuyCount);

    //购买种子
    int BuySeed(CUesrGardenData& stUserGarden, int& iGold, int iNow, int iMaxCanBuyCount);

    //求助
    int SeekHelp(unsigned int uiGID, CUesrGardenData& stUserGarden, 
                        unsigned int uiFriendGID, CUesrGardenData& stFriendUserGarden, int iNowTime);
    ///////////////////////////配置相关///////////////////////////////////////////

    int GetFlowerConfig(unsigned char ucFlowerID, CGardenFlowerConfigData& stConfigData)
    {
        return _stGardenFlowerConfig.GetConfig(ucFlowerID, stConfigData);
    }

    int GetRoleLevelConfig(unsigned short usLevel, CGardenRoleLevelConfigData& stConfigData)
    {
        return _stGardenRoleLevelConfig.GetConfig(usLevel, stConfigData);
    }

    int GetNextLandLevelConfig(unsigned char ucNowLandLevel, unsigned char ucNowPos, CGardenLandConfigData& stConfigData)
    {
        return _stGardenLandConfig.GetNextLevelConfig(ucNowLandLevel, ucNowPos, stConfigData);
    }

private:
    CGardenLandConfig _stGardenLandConfig;
    CGardenRoleLevelConfig _stGardenRoleLevelConfig;
    CGardenShopConfig _stGardenShopConfig;
    CGardenFlowerConfig _stGardenFlowerConfig;
};


#endif // __CGardenMgr_h__

